package it.asvp.asvp_portal.data.entity.event;

import it.asvp.asvp_portal.data.entity.domain.BaseEntity;
import it.asvp.asvp_portal.data.entity.domain.File;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;

@Entity
@Table(name = "event_picture", catalog = "asvp_db", uniqueConstraints = @UniqueConstraint(columnNames = { "id_event", "id_picture" }))
public class EventPicture extends BaseEntity {

  private static final long serialVersionUID = 6281871811501267976L;

  @ManyToOne(fetch = FetchType.EAGER)
  @JoinColumn(name = "id_event", nullable = false)
  private Event             event;

  @ManyToOne(fetch = FetchType.EAGER)
  @JoinColumn(name = "id_picture", nullable = false)
  @Cascade({ CascadeType.ALL })
  private File              picture;

  public EventPicture() {
  }

  public EventPicture(Event event, File picture) {
    this.event = event;
    this.picture = picture;
  }

  public Event getEvent() {
    return this.event;
  }

  public void setEvent(Event event) {
    this.event = event;
  }

  public File getPicture() {
    return this.picture;
  }

  public void setPicture(File file) {
    this.picture = file;
  }

}
